import sys
def _input_iter():
for line in sys.stdin:
for part in line.strip().split(' '):
stripped = part.strip()
if stripped:
yield stripped
stream = _input_iter()
def read_int():
return int(next(stream))
def read_str():
return next(stream)
def run():
n = read_int()
arr_even = []
arr_odd = []
for i in range(n):
cur = read_int()
if cur % 2 != 0:
arr_odd.append(cur)
else:
arr_even.append(cur)
curr_even = -1
curr_odd = -1
for i in range(len(arr_odd)):
if curr_odd > arr_odd[i]:
print("NO")
return
else:
curr_odd = arr_odd[i]
for i in range(len(arr_even)):
if curr_even > arr_even[i]:
print("NO")
return
else:
curr_even = arr_even[i]
print("YES")
test_cases = read_int()
for _ in range(test_cases):
run()
#include <bits/stdc++.h>
using namespace std;
#define gogo ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const string YES = "YES";
const string NO = "NO";
void run() {
int n;
cin >> n;
vector<int> even, odd;
for (int i = 0;i < n;i ++) {
int x;
cin >> x;
if (x & 1)
odd.push_back(x);
else
even.push_back(x);
}
if (is_sorted(even.begin(), even.end()) && is_sorted(odd.begin(), odd.end()))
cout << "Yes" << endl;
else
cout << "No" << endl;
}
int32_t main() {
gogo;
int tt;
cin >> tt;
while (tt --)
run();
return 0;
}
1562B - Scenes From a Memory | 1521A - Nastia and Nearly Good Numbers |
208. Implement Trie | 1605B - Reverse Sort |
1607C - Minimum Extraction | 1604B - XOR Specia-LIS-t |
1606B - Update Files | 1598B - Groups |
1602B - Divine Array | 1594B - Special Numbers |
1614A - Divan and a Store | 2085. Count Common Words With One Occurrence |
2089. Find Target Indices After Sorting Array | 2090. K Radius Subarray Averages |
2091. Removing Minimum and Maximum From Array | 6. Zigzag Conversion |
1612B - Special Permutation | 1481. Least Number of Unique Integers after K Removals |
1035. Uncrossed Lines | 328. Odd Even Linked List |
1219. Path with Maximum Gold | 1268. Search Suggestions System |
841. Keys and Rooms | 152. Maximum Product Subarray |
337. House Robber III | 869. Reordered Power of 2 |
1593C - Save More Mice | 1217. Minimum Cost to Move Chips to The Same Position |
347. Top K Frequent Elements | 1503. Last Moment Before All Ants Fall Out of a Plank |